package com.baiyun.service.impl;

import com.baiyun.entity.Sale;
import com.baiyun.mapper.SalesMapper;
import com.baiyun.service.SalesService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.util.List;

@Service
@RequiredArgsConstructor
public class SalesServiceImpl implements SalesService {
    private final SalesMapper salesMapper;

    @Override
    public List<Sale> selectAllSales() {
        return salesMapper.selectAllSales();
    }

    @Override
    public void addSales(Sale sale) {
        sale.setTime(new Date(System.currentTimeMillis()));
        salesMapper.addSales(sale);
    }

    @Override
    public void updateSales(Sale sale) {
        sale.setTime(new Date(System.currentTimeMillis()));
        salesMapper.updateSales(sale);
    }

    @Override
    public void deleteSales(Integer sid) {
        salesMapper.deleteSales(sid);
    }

    @Override
    public Sale getSaleById(Integer sid) {
        return salesMapper.getSaleById(sid);
    }
}
